
package Controller;

import Connection.DataAccess;
import Model.NhaCC;

/**
 *
 * @author My PC
 */
public class NhaCCController {
    public static boolean ThemNCC(NhaCC ncc)
    {
        try 
        {
            
           String sql = "insert into tblNhaCungCap(MA_NHACUNGCAP,"
                + " TEN_NHACUNGCAP,DIACHI,DIENTHOAI,EMAIL) "
                + "values (N'"+ncc.getMaNhacc()+"',N'"+ncc.getTenNhacc()+"',"
                + "N'"+ncc.getDiachi()+"',N'"+ncc.getDienthoai()+"',"
                + "N'"+ncc.getEmail()+"')";
                  
           DataAccess da=new DataAccess();
           da.executeUpdate(sql);
            return true;
        } catch (Exception e) {
            return false;
        }
    }
     public static boolean XoaNCC(NhaCC ncc)
    {
        try 
        {
            
           String sql = String.format("delete from tblNhaCungCap where MA_NHACUNGCAP =N'%s'",ncc.getMaNhacc());
           DataAccess da=new DataAccess();
           da.executeUpdate(sql);
            return true;
        } catch (Exception e) {
            return false;
        }
    }
     public static boolean SuaNCC(NhaCC ncc)
    {
        try 
        {
            
           String sql = "UPDATE tblNhaCungCap SET "
                   + "TEN_NHACUNGCAP = N'"+ncc.getTenNhacc()+"',"
                   + "DiaChi = N'"+ncc.getDiachi()+"',"
                   + "DIENTHOAI = N'"+ncc.getDienthoai()+"',EMAIL = N'"+ncc.getEmail()+"'"
                   + " WHERE MA_NHACUNGCAP = N'"+ncc.getMaNhacc()+"'";              
           DataAccess da=new DataAccess();
           da.executeUpdate(sql);
            return true;
        } catch (Exception e) {
            return false;
        }
    }
    
    
}
